/*
*    Phantom v2.0 GUI Automation Software
*    Copyright (C) 2009  John C. Van Arsdall (john@phantomtest.com)
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License along
*    with this program; if not, write to the Free Software Foundation, Inc.,
*    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#pragma once

#include "ssi_defines.h"
#include "ssi_status.h"
#include "ssi_string.h"
#include "ssi_data.h"

#define SSI_EXTRACT(x,y) ((x*)(CData*)*(theAPI[y]))->Data
#define SSI_EXTRACT_D(x,y) ((x*)(CData*)*(theAPI[y]))

class CEngine;
class CFunctionSet;
class SSI_SCRIPTDLL_API SSI_FunctionAPI
{
	friend class CEngine;
	friend class CFunctionSet;
	friend class CData;
public:
	SSI_FunctionAPI(void);
	virtual ~SSI_FunctionAPI(void);
	CStatus m_ReturnStatus;
	String m_FunctionName;
  CVariable* operator[](SSI_INT64 Index);

private:
	static SSI_INT64 m_Version;
protected:
	CVariable RetVar;
	CVariable** Parameters;
public:
	SSI_INT64 GetVersion(void);
  virtual CStatus SetReturnData(CVariable* aVar);
	virtual CStatus SetReturnData(CData* Data);
  
	// This function needs to be made protected so cannot access in other DLLs (else memory violation)
	// Remember to consider this when deciding which functions to put in Script API
	virtual CVariable* GetReturnData();
	CEngine* m_Engine;   // SHOULD BE CAREFUL WITH THIS, BUT NEEDED FOR CLASS DATA TYPES AND OTHER FUNCTIONS

	virtual void ClearParameters(void);
	virtual SSI_INT64 GetNumParams(void);
	virtual SSI_BOOL AddParameter(CVariable& aVar, SSI_INT64 Index);
	virtual SSI_BOOL InitParams(SSI_INT64 NumParams);

	SSI_INT64 GetParameterType(SSI_INT64 Index);
	SSI_FunctionAPI& operator =(SSI_FunctionAPI &Other);
	CVariable** CopyParameters(CVariable** Others, SSI_INT64 Count);
  CData* GetSingleData(SSI_INT64 I);
};



